package com.lx.mobileplayer.mvp.view.adapter


import android.widget.ImageView
import android.widget.TextView
import com.lx.mobileplayer.R
import com.lx.mobileplayer.ext.loadImage
import com.lx.mobileplayer.mvp.model.HomeItemBean

/**
 * 类说明：首页的adapter
 * Created by liuxiong on 2019/4/24.
 */
class HomeAdapter(data:ArrayList<HomeItemBean>): BaseListAdapter<HomeItemBean>(R.layout.item_home,data) {

    constructor():this(ArrayList<HomeItemBean>())

    override fun onBindDataToView(holder: BaseViewHodler, bean: HomeItemBean) {
        if(bean.thumbnailPic==null){
            holder.getView<ImageView>(R.id.bg)?.loadImage("https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=2153937626,1074119156&fm=27&gp=0.jpg")
        }
        bean.thumbnailPic?.let{
            holder.getView<ImageView>(R.id.bg)?.loadImage(bean.thumbnailPic)
        }

        holder.getView<ImageView>(R.id.image)?.loadImage(R.mipmap.home_page_activity)
        holder.getView<TextView>(R.id.title)?.text = bean.title
        holder.getView<TextView>(R.id.desc)?.text=bean.description
    }
}